package com.david.files.service.impl;

import com.david.files.mapper.FileMapper;
import com.david.files.pojo.Entity.FileEntity;
import com.david.files.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class FileServiceImpl implements FileService {
    @Autowired
    private FileMapper fileMapper;
    @Override
    @Transactional
    public void upload(FileEntity fileEntity) {
        System.out.println(fileEntity);
        fileMapper.delete(fileEntity);
        fileMapper.insertFile(fileEntity);

    }

    @Override
    public List<FileEntity> getList(FileEntity file) {
        return fileMapper.selectByEntity(file);
    }

    @Override
    public void delDoc(Integer id) {
        fileMapper.deleteById(id);
    }

}
